package com.zrrd.straw1.mapper;

import com.zrrd.straw1.entity.Question;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author zrrd
* @since 2024-03-03
*/
@Repository
public interface QuestionMapper extends BaseMapper<Question> {
    @Select("select q.* " +
            " from user u " +
            " join user_question uq on u.id = uq.user_id " +
            " join question q       on uq.question_id = q.id " +
            " where u.id = #{id} ")
    List<Question> findTeacherQuestions(Integer id);

    //修改问题的状态，用来显示页面中不同的标签
    @Update("update question set status = #{status} where id = #{questionId}")
    Integer udpateStatus(Integer questionId, Integer status);

    Integer updateStatus(Integer id, Integer solved);
}
